package com.oragraph.gui;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JTextArea;

import com.oragraph.data.Node;

public class EditFilterDialog extends JDialog {
	
	private Node _node;
	private JTextArea _textArea;
	
	public EditFilterDialog(Node n) {
		super(MainFrame.singleton, "Edit filter", true);
		
		_node=n;
		
		_textArea=new JTextArea(_node.getMutableProperties().get("filter"), 10, 60);
		
		JButton saveButton=new JButton("Save");
		saveButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            	_node.getMutableProperties().set("filter", _textArea.getText());
            	setVisible(false);
            }
        });	
				
		JButton cancelButton=new JButton("Cancel");
		cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            	setVisible(false);
            }
        });
		
		JPanel buttonPanel=new JPanel();
		buttonPanel.add(saveButton);
		buttonPanel.add(cancelButton);
				
		this.getContentPane().setLayout(new BorderLayout());
		this.getContentPane().add(_textArea, BorderLayout.CENTER);
		this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);		
		
		pack();
	}

}